#pragma once

#include "Sheet.h"
#include "Sheet.h"

// ============================================================================

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections::Generic;
using namespace System::Windows::Forms;
using namespace System::Drawing;

/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
///          'Resource File Name' property for the managed resource compiler tool
///          associated with all .resx files this class depends on.  Otherwise,
///          the designers will not be able to interact properly with localized
///          resources associated with this form.
/// </summary>

public ref class Form1 : public System::Windows::Forms::Form
{
private: System::Windows::Forms::SplitContainer^  splitContainer3;
private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^  newToolStripMenuItem1;
private: System::Windows::Forms::ToolStripMenuItem^  openToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^  saveToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^  saveAsToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem1;
private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;
private: System::Windows::Forms::ComboBox^  comboBoxTreeFilter;
private: System::Windows::Forms::ComboBox^  comboBoxPortFilter;
private: System::Windows::Forms::TextBox^  textBoxLog;
private: System::Windows::Forms::Label^  label1;
private: System::Windows::Forms::Label^  label2;
private: System::Windows::Forms::ToolStripMenuItem^  pauseAllToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem2;
private: System::Windows::Forms::ToolStripMenuItem^  startAllToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^  stopAllToolStripMenuItem;
private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem3;
private: System::Windows::Forms::ToolStripMenuItem^  resumeAllToolStripMenuItem;
private: Sheet^ sheet;

public:
	Form1(void)
	{
		InitializeComponent();

		//
		//TODO: Add the constructor code here
		//
		comboBoxTree->SelectedIndex = 0;
		comboBoxPortFilter->SelectedIndex = 0;
		comboBoxTreeFilter->SelectedIndex = 0;
		sheet = gcnew Sheet (textBoxLog, comboBoxPortFilter, comboBoxTreeFilter, propertyGridBridgeOrPort, propertyGridTree);
		sheet->Dock = DockStyle::Fill;
		sheet->Parent = splitContainer3->Panel1;
	}

protected:
	/// <summary>
	/// Clean up any resources being used.
	/// </summary>
	~Form1()
	{
		if (components)
		{
			delete components;
		}
	}
private: System::Windows::Forms::PropertyGrid^  propertyGridTree;
private: System::Windows::Forms::SplitContainer^  splitContainer1;
private: System::Windows::Forms::MenuStrip^  menuStrip1;
private: System::Windows::Forms::ToolStripMenuItem^  bridgeToolStripMenuItem;
private: System::Windows::Forms::ToolStripMenuItem^  newToolStripMenuItem;
private: System::Windows::Forms::ComboBox^  comboBoxTree;
private: System::Windows::Forms::SplitContainer^  splitContainer2;
private: System::Windows::Forms::PropertyGrid^  propertyGridBridgeOrPort;
private: System::ComponentModel::IContainer^  components;

private:
	/// <summary>
	/// Required designer variable.
	/// </summary>


#pragma region Windows Form Designer generated code
	/// <summary>
	/// Required method for Designer support - do not modify
	/// the contents of this method with the code editor.
	/// </summary>
	void InitializeComponent(void)
	{
		this->label1 = (gcnew System::Windows::Forms::Label());
		this->label2 = (gcnew System::Windows::Forms::Label());
		this->propertyGridTree = (gcnew System::Windows::Forms::PropertyGrid());
		this->splitContainer1 = (gcnew System::Windows::Forms::SplitContainer());
		this->splitContainer2 = (gcnew System::Windows::Forms::SplitContainer());
		this->propertyGridBridgeOrPort = (gcnew System::Windows::Forms::PropertyGrid());
		this->comboBoxTree = (gcnew System::Windows::Forms::ComboBox());
		this->splitContainer3 = (gcnew System::Windows::Forms::SplitContainer());
		this->comboBoxTreeFilter = (gcnew System::Windows::Forms::ComboBox());
		this->comboBoxPortFilter = (gcnew System::Windows::Forms::ComboBox());
		this->textBoxLog = (gcnew System::Windows::Forms::TextBox());
		this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
		this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->newToolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->openToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->saveToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->saveAsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripSeparator());
		this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->bridgeToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->newToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->toolStripMenuItem2 = (gcnew System::Windows::Forms::ToolStripSeparator());
		this->startAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->stopAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->toolStripMenuItem3 = (gcnew System::Windows::Forms::ToolStripSeparator());
		this->pauseAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->resumeAllToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
		this->splitContainer1->Panel1->SuspendLayout();
		this->splitContainer1->Panel2->SuspendLayout();
		this->splitContainer1->SuspendLayout();
		this->splitContainer2->Panel1->SuspendLayout();
		this->splitContainer2->Panel2->SuspendLayout();
		this->splitContainer2->SuspendLayout();
		this->splitContainer3->Panel2->SuspendLayout();
		this->splitContainer3->SuspendLayout();
		this->menuStrip1->SuspendLayout();
		this->SuspendLayout();
		// 
		// label1
		// 
		this->label1->Location = System::Drawing::Point(4, 4);
		this->label1->Name = L"label1";
		this->label1->Size = System::Drawing::Size(42, 23);
		this->label1->TabIndex = 3;
		this->label1->Text = L"Tree";
		this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
		// 
		// label2
		// 
		this->label2->Location = System::Drawing::Point(9, 6);
		this->label2->Name = L"label2";
		this->label2->Size = System::Drawing::Size(79, 24);
		this->label2->TabIndex = 9;
		this->label2->Text = L"Filter log";
		this->label2->TextAlign = System::Drawing::ContentAlignment::MiddleRight;
		// 
		// propertyGridTree
		// 
		this->propertyGridTree->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
			| System::Windows::Forms::AnchorStyles::Left) 
			| System::Windows::Forms::AnchorStyles::Right));
		this->propertyGridTree->Location = System::Drawing::Point(3, 33);
		this->propertyGridTree->Name = L"propertyGridTree";
		this->propertyGridTree->Size = System::Drawing::Size(169, 381);
		this->propertyGridTree->TabIndex = 1;
		// 
		// splitContainer1
		// 
		this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill;
		this->splitContainer1->Location = System::Drawing::Point(0, 28);
		this->splitContainer1->Name = L"splitContainer1";
		// 
		// splitContainer1.Panel1
		// 
		this->splitContainer1->Panel1->Controls->Add(this->splitContainer2);
		// 
		// splitContainer1.Panel2
		// 
		this->splitContainer1->Panel2->Controls->Add(this->splitContainer3);
		this->splitContainer1->Size = System::Drawing::Size(969, 680);
		this->splitContainer1->SplitterDistance = 175;
		this->splitContainer1->TabIndex = 2;
		// 
		// splitContainer2
		// 
		this->splitContainer2->Dock = System::Windows::Forms::DockStyle::Fill;
		this->splitContainer2->Location = System::Drawing::Point(0, 0);
		this->splitContainer2->Name = L"splitContainer2";
		this->splitContainer2->Orientation = System::Windows::Forms::Orientation::Horizontal;
		// 
		// splitContainer2.Panel1
		// 
		this->splitContainer2->Panel1->Controls->Add(this->propertyGridBridgeOrPort);
		// 
		// splitContainer2.Panel2
		// 
		this->splitContainer2->Panel2->Controls->Add(this->label1);
		this->splitContainer2->Panel2->Controls->Add(this->comboBoxTree);
		this->splitContainer2->Panel2->Controls->Add(this->propertyGridTree);
		this->splitContainer2->Size = System::Drawing::Size(175, 680);
		this->splitContainer2->SplitterDistance = 259;
		this->splitContainer2->TabIndex = 3;
		// 
		// propertyGridBridgeOrPort
		// 
		this->propertyGridBridgeOrPort->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
			| System::Windows::Forms::AnchorStyles::Left) 
			| System::Windows::Forms::AnchorStyles::Right));
		this->propertyGridBridgeOrPort->Location = System::Drawing::Point(3, 3);
		this->propertyGridBridgeOrPort->Name = L"propertyGridBridgeOrPort";
		this->propertyGridBridgeOrPort->Size = System::Drawing::Size(169, 253);
		this->propertyGridBridgeOrPort->TabIndex = 0;
		// 
		// comboBoxTree
		// 
		this->comboBoxTree->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Left) 
			| System::Windows::Forms::AnchorStyles::Right));
		this->comboBoxTree->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
		this->comboBoxTree->Enabled = false;
		this->comboBoxTree->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"CIST", L"MSTI1", L"MSTI2"});
		this->comboBoxTree->Location = System::Drawing::Point(52, 3);
		this->comboBoxTree->MaxDropDownItems = 20;
		this->comboBoxTree->Name = L"comboBoxTree";
		this->comboBoxTree->Size = System::Drawing::Size(120, 24);
		this->comboBoxTree->TabIndex = 2;
		this->comboBoxTree->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::comboBoxTree_SelectedIndexChanged);
		// 
		// splitContainer3
		// 
		this->splitContainer3->Dock = System::Windows::Forms::DockStyle::Fill;
		this->splitContainer3->Location = System::Drawing::Point(0, 0);
		this->splitContainer3->Name = L"splitContainer3";
		// 
		// splitContainer3.Panel2
		// 
		this->splitContainer3->Panel2->Controls->Add(this->comboBoxTreeFilter);
		this->splitContainer3->Panel2->Controls->Add(this->comboBoxPortFilter);
		this->splitContainer3->Panel2->Controls->Add(this->label2);
		this->splitContainer3->Panel2->Controls->Add(this->textBoxLog);
		this->splitContainer3->Size = System::Drawing::Size(790, 680);
		this->splitContainer3->SplitterDistance = 325;
		this->splitContainer3->TabIndex = 0;
		// 
		// comboBoxTreeFilter
		// 
		this->comboBoxTreeFilter->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
		this->comboBoxTreeFilter->FormattingEnabled = true;
		this->comboBoxTreeFilter->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"(all trees)", L"CIST", L"MSTI1", L"MSTI2"});
		this->comboBoxTreeFilter->Location = System::Drawing::Point(282, 6);
		this->comboBoxTreeFilter->Name = L"comboBoxTreeFilter";
		this->comboBoxTreeFilter->Size = System::Drawing::Size(182, 24);
		this->comboBoxTreeFilter->TabIndex = 11;
		// 
		// comboBoxPortFilter
		// 
		this->comboBoxPortFilter->DropDownStyle = System::Windows::Forms::ComboBoxStyle::DropDownList;
		this->comboBoxPortFilter->FormattingEnabled = true;
		this->comboBoxPortFilter->Items->AddRange(gcnew cli::array< System::Object^  >(4) {L"(all ports)", L"PortA", L"PortB", L"PortRMII"});
		this->comboBoxPortFilter->Location = System::Drawing::Point(94, 6);
		this->comboBoxPortFilter->Name = L"comboBoxPortFilter";
		this->comboBoxPortFilter->Size = System::Drawing::Size(182, 24);
		this->comboBoxPortFilter->TabIndex = 10;
		// 
		// textBoxLog
		// 
		this->textBoxLog->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
			| System::Windows::Forms::AnchorStyles::Left) 
			| System::Windows::Forms::AnchorStyles::Right));
		this->textBoxLog->BackColor = System::Drawing::SystemColors::Window;
		this->textBoxLog->Font = (gcnew System::Drawing::Font(L"Consolas", 8, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
			static_cast<System::Byte>(238)));
		this->textBoxLog->Location = System::Drawing::Point(3, 36);
		this->textBoxLog->Multiline = true;
		this->textBoxLog->Name = L"textBoxLog";
		this->textBoxLog->ReadOnly = true;
		this->textBoxLog->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
		this->textBoxLog->Size = System::Drawing::Size(455, 641);
		this->textBoxLog->TabIndex = 8;
		// 
		// menuStrip1
		// 
		this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->fileToolStripMenuItem, 
			this->bridgeToolStripMenuItem});
		this->menuStrip1->Location = System::Drawing::Point(0, 0);
		this->menuStrip1->Name = L"menuStrip1";
		this->menuStrip1->Size = System::Drawing::Size(969, 28);
		this->menuStrip1->TabIndex = 3;
		this->menuStrip1->Text = L"menuStrip1";
		// 
		// fileToolStripMenuItem
		// 
		this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(6) {this->newToolStripMenuItem1, 
			this->openToolStripMenuItem, this->saveToolStripMenuItem, this->saveAsToolStripMenuItem, this->toolStripMenuItem1, this->exitToolStripMenuItem});
		this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
		this->fileToolStripMenuItem->Size = System::Drawing::Size(44, 24);
		this->fileToolStripMenuItem->Text = L"&File";
		// 
		// newToolStripMenuItem1
		// 
		this->newToolStripMenuItem1->Name = L"newToolStripMenuItem1";
		this->newToolStripMenuItem1->Size = System::Drawing::Size(129, 24);
		this->newToolStripMenuItem1->Text = L"&New";
		// 
		// openToolStripMenuItem
		// 
		this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
		this->openToolStripMenuItem->Size = System::Drawing::Size(129, 24);
		this->openToolStripMenuItem->Text = L"&Open";
		this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openToolStripMenuItem_Click);
		// 
		// saveToolStripMenuItem
		// 
		this->saveToolStripMenuItem->Name = L"saveToolStripMenuItem";
		this->saveToolStripMenuItem->Size = System::Drawing::Size(129, 24);
		this->saveToolStripMenuItem->Text = L"&Save";
		this->saveToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveToolStripMenuItem_Click);
		// 
		// saveAsToolStripMenuItem
		// 
		this->saveAsToolStripMenuItem->Name = L"saveAsToolStripMenuItem";
		this->saveAsToolStripMenuItem->Size = System::Drawing::Size(129, 24);
		this->saveAsToolStripMenuItem->Text = L"&Save As";
		// 
		// toolStripMenuItem1
		// 
		this->toolStripMenuItem1->Name = L"toolStripMenuItem1";
		this->toolStripMenuItem1->Size = System::Drawing::Size(126, 6);
		// 
		// exitToolStripMenuItem
		// 
		this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
		this->exitToolStripMenuItem->Size = System::Drawing::Size(129, 24);
		this->exitToolStripMenuItem->Text = L"E&xit";
		// 
		// bridgeToolStripMenuItem
		// 
		this->bridgeToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(7) {this->newToolStripMenuItem, 
			this->toolStripMenuItem2, this->startAllToolStripMenuItem, this->stopAllToolStripMenuItem, this->toolStripMenuItem3, this->pauseAllToolStripMenuItem, 
			this->resumeAllToolStripMenuItem});
		this->bridgeToolStripMenuItem->Name = L"bridgeToolStripMenuItem";
		this->bridgeToolStripMenuItem->Size = System::Drawing::Size(65, 24);
		this->bridgeToolStripMenuItem->Text = L"&Bridge";
		// 
		// newToolStripMenuItem
		// 
		this->newToolStripMenuItem->Name = L"newToolStripMenuItem";
		this->newToolStripMenuItem->Size = System::Drawing::Size(152, 24);
		this->newToolStripMenuItem->Text = L"&New...";
		this->newToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::newToolStripMenuItem_Click);
		// 
		// toolStripMenuItem2
		// 
		this->toolStripMenuItem2->Name = L"toolStripMenuItem2";
		this->toolStripMenuItem2->Size = System::Drawing::Size(149, 6);
		// 
		// startAllToolStripMenuItem
		// 
		this->startAllToolStripMenuItem->Name = L"startAllToolStripMenuItem";
		this->startAllToolStripMenuItem->Size = System::Drawing::Size(152, 24);
		this->startAllToolStripMenuItem->Text = L"Start All";
		this->startAllToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::startAllToolStripMenuItem_Click);
		// 
		// stopAllToolStripMenuItem
		// 
		this->stopAllToolStripMenuItem->Name = L"stopAllToolStripMenuItem";
		this->stopAllToolStripMenuItem->Size = System::Drawing::Size(152, 24);
		this->stopAllToolStripMenuItem->Text = L"Stop All";
		// 
		// toolStripMenuItem3
		// 
		this->toolStripMenuItem3->Name = L"toolStripMenuItem3";
		this->toolStripMenuItem3->Size = System::Drawing::Size(149, 6);
		// 
		// pauseAllToolStripMenuItem
		// 
		this->pauseAllToolStripMenuItem->Name = L"pauseAllToolStripMenuItem";
		this->pauseAllToolStripMenuItem->Size = System::Drawing::Size(152, 24);
		this->pauseAllToolStripMenuItem->Text = L"Pause All";
		this->pauseAllToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::pauseAllToolStripMenuItem_Click);
		// 
		// resumeAllToolStripMenuItem
		// 
		this->resumeAllToolStripMenuItem->Name = L"resumeAllToolStripMenuItem";
		this->resumeAllToolStripMenuItem->Size = System::Drawing::Size(152, 24);
		this->resumeAllToolStripMenuItem->Text = L"Resume All";
		this->resumeAllToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::resumeAllToolStripMenuItem_Click);
		// 
		// Form1
		// 
		this->AutoScaleDimensions = System::Drawing::SizeF(120, 120);
		this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Dpi;
		this->ClientSize = System::Drawing::Size(969, 708);
		this->Controls->Add(this->splitContainer1);
		this->Controls->Add(this->menuStrip1);
		this->Margin = System::Windows::Forms::Padding(4);
		this->Name = L"Form1";
		this->Text = L"Form1";
		this->WindowState = System::Windows::Forms::FormWindowState::Maximized;
		this->splitContainer1->Panel1->ResumeLayout(false);
		this->splitContainer1->Panel2->ResumeLayout(false);
		this->splitContainer1->ResumeLayout(false);
		this->splitContainer2->Panel1->ResumeLayout(false);
		this->splitContainer2->Panel2->ResumeLayout(false);
		this->splitContainer2->ResumeLayout(false);
		this->splitContainer3->Panel2->ResumeLayout(false);
		this->splitContainer3->Panel2->PerformLayout();
		this->splitContainer3->ResumeLayout(false);
		this->menuStrip1->ResumeLayout(false);
		this->menuStrip1->PerformLayout();
		this->ResumeLayout(false);
		this->PerformLayout();

	}
#pragma endregion

	void newToolStripMenuItem_Click (Object^ sender, EventArgs^ e)
	{
		sheet->AddNewBridge (3);
	}

	void comboBoxTree_SelectedIndexChanged (Object^ sender, EventArgs^ e)
	{
		this->propertyGridTree->SelectedObject = this->propertyGridTree->SelectedObject;
	}
/*
	void OnBridgeOrPortPropertiesChanged (Object^ bridgeOrPortObject, Object^ bridgeOrPortTreeObject)
	{
		this->propertyGridBridgeOrPort->SelectedObject = bridgeOrPortObject;
		this->propertyGridBridgeOrPort->ExpandAllGridItems ();

		this->propertyGridTree->SelectedObject = bridgeOrPortTreeObject;
		this->propertyGridTree->ExpandAllGridItems ();
	}
*/
	void pauseAllToolStripMenuItem_Click (Object^ sender, EventArgs^ e)
	{
		sheet->PauseAll ();
	}

	void resumeAllToolStripMenuItem_Click (Object^ sender, EventArgs^ e)
	{
		sheet->ResumeAll ();
	}

	void startAllToolStripMenuItem_Click (Object^ sender, EventArgs^ e)
	{
		sheet->StartAll ();
	}

	void saveToolStripMenuItem_Click(Object^ sender, EventArgs^ e)
	{
		sheet->SaveToFile (L"C:\\aa.txt");
	}

	void openToolStripMenuItem_Click (Object^ sender, EventArgs^ e)
	{
		sheet->LoadFromFile (L"C:\\aa.txt");
	}
};

